package com.gouqi.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gouqi.common.DeleteRequest;
import com.gouqi.model.dto.question.QuestionAddRequest;
import com.gouqi.model.dto.question.QuestionEditRequest;
import com.gouqi.model.dto.question.QuestionQueryRequest;
import com.gouqi.model.dto.question.QuestionUpdateRequest;
import com.gouqi.model.entity.Question;
import com.gouqi.model.vo.QuestionVO;

import javax.servlet.http.HttpServletRequest;

public interface QuestionService extends IService<Question> {
    /**
     * 校验数据
     *
     * @param question
     * @param add      对创建的数据进行校验
     */
    void validQuestion(Question question, boolean add);

    /**
     * 获取查询条件
     *
     * @param questionQueryRequest
     * @return
     */
    LambdaQueryWrapper<Question> getQueryWrapper(QuestionQueryRequest questionQueryRequest);

    /**
     * 获取题目封装
     *
     * @param question
     * @param request
     * @return
     */
    QuestionVO getQuestionVO(Question question, HttpServletRequest request);

    /**
     * 分页获取题目封装
     *
     * @param questionPage
     * @param request
     * @return
     */
    Page<QuestionVO> getQuestionVOPage(Page<Question> questionPage, HttpServletRequest request);

    /**
     * 创建题目
     *
     * @param questionAddRequest
     * @param request
     * @return
     */
    long addQuestion(QuestionAddRequest questionAddRequest, HttpServletRequest request);

    /**
     * 删除题目
     *
     * @param deleteRequest
     * @param request
     */
    void deleteQuestion(DeleteRequest deleteRequest, HttpServletRequest request);

    /**
     * 更新题目（仅管理员可用）
     *
     * @param questionUpdateRequest
     */
    void updateQuestion(QuestionUpdateRequest questionUpdateRequest);

    /**
     * 获得题目
     *
     * @param id
     * @param request
     * @return
     */
    QuestionVO getQuestion(long id, HttpServletRequest request);

    /**
     * 分页获取题目列表（仅管理员可用）
     *
     * @param questionQueryRequest
     * @return
     */
    Page<Question> getQuestionPage(QuestionQueryRequest questionQueryRequest);

    /**
     * 分页获取题目列表（封装类）
     *
     * @param questionQueryRequest
     * @param request
     * @return
     */
    Page<QuestionVO> getQuestionVOByPage(QuestionQueryRequest questionQueryRequest, HttpServletRequest request);

    /**
     * 分页获取当前登录用户创建的题目列表
     *
     * @param questionQueryRequest
     * @param request
     * @return
     */
    Page<QuestionVO> getMyQuestionVOPage(QuestionQueryRequest questionQueryRequest, HttpServletRequest request);

    /**
     * 编辑题目 （给用户使用）
     *
     * @param questionEditRequest
     * @param request
     */
    void editQuestion(QuestionEditRequest questionEditRequest, HttpServletRequest request);

}
